namespace IrisGenerator.Common.Modules
{
    using System.Collections.ObjectModel;
    using System;
    using System.Linq;
    using IrisGenerator.Common.Modules;
    
    
    public partial class ModuleCollection : Collection<Module> {

        /// <summary>
        /// Checks if a module exists in the current collection
        /// </summary>
        /// <param name="module">The module to look for in the collection</param>
        /// <remarks>Existance is tested upon 3 values: Module's name and Module's version</remarks>
        /// <returns>Returns true if a module with such a name and version exists in the collection</returns>
        public bool Exists(Module module)
        {
            Module mod = (from mods in this
                      where mods.ModName == module.ModName
                      select mods).SingleOrDefault();

            if (mod != null)
                return true;

            return false;
        }

        public Module Find(string name)
        {
            Module mod = (from mods in this
                          where mods.ModName == name
                          select mods).SingleOrDefault();

            return mod;
        }

    }
}
